#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<stdio.h>
int main()
{
    pid_t id=fork();
    if(id==0)//child
    {
        int cnt=5;
        while(cnt--)
        {
            printf("I am child process\n");
            sleep(1);
        }
        _exit(9);//exitcode
    }
    //parent
    int status;
    pid_t wid=wait(&status);
    if(wid>0)
        printf("child exit code=%d,child exit signal:%d\n",(status>>8)&0xFF,status&0x7F);
    return 0;
}
